package com.houtai.staservice.controller;


import com.houtai.commonutils.Result;
import com.houtai.eduservice.config.OperationLogDesc;
import com.houtai.staservice.service.StatisticsDailyService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lin
 * @since 2022-12-16
 */
@RestController
@RequestMapping("/edusta/sta")
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService statisticsDailyService;
    //统计某一天注册人数,生成统计数据
    @PostMapping("registerCount/{day}")
    @OperationLogDesc(module = "统计数据模块",description = "生成统计数据")
    public Result registerCount(@PathVariable String day) {
        statisticsDailyService.registerCount(day);
        return Result.ok();
    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("showData/{type}/{begin}/{end}")
    @OperationLogDesc(module = "统计数据模块",description = "生成统计图表")
    public Result showData(@PathVariable String type,@PathVariable String begin,
                      @PathVariable String end) {
        Map<String,Object> map = statisticsDailyService.getShowData(type,begin,end);
        return Result.ok().data(map);
    }

}

